#!/usr/bin/env python3
"""
系统配置Pydantic模式
"""

from datetime import datetime


from pydantic import BaseModel, Field


class SystemConfigBase(BaseModel):
    """系统配置基础模型"""

    key: str = Field(..., description="配置键名")
    value: str | None = Field(None, description="配置值")
    description: str | None = Field(None, description="配置描述")
    is_encrypted: bool = Field(False, description="是否加密")


class SystemConfigCreate(BaseModel):
    """系统配置创建模型"""

    key: str = Field(..., description="配置键名")
    value: str = Field(..., description="配置值")
    description: str | None = Field(None, description="配置描述")
    is_encrypted: bool = Field(False, description="是否加密")


class SystemConfigUpdate(BaseModel):
    """系统配置更新模型"""

    value: str | None = Field(None, description="配置值")
    description: str | None = Field(None, description="配置描述")
    is_encrypted: bool | None = Field(None, description="是否加密")


class SystemConfigResponse(BaseModel):
    """系统配置响应模型"""

    config: SystemConfigBase = Field(..., description="系统配置")
    created_at: datetime | None = Field(None, description="创建时间")
    updated_at: datetime | None = Field(None, description="更新时间")

    class Config:
        from_attributes = True


class SystemConfigListResponse(BaseModel):
    """系统配置列表响应模型"""

    configs: list[SystemConfigBase] = Field(..., description="配置列表")
    total: int = Field(..., description="总数")
    skip: int = Field(..., description="跳过数量")
    limit: int = Field(..., description="限制数量")
